46b3ff1e83311b28eebbff0056061c458169bd48,src/org/opencms/flex/CmsFlexCacheKey.java,CmsFlexCacheKey,matchRequestKey,#CmsFlexRequestKey#,211

Before Change



        if (m_uri != null) {
            str.append("uri=(");
            str.append(key.getUri());
            str.append(");");
        }

        if (m_element != null) {
            str.append("element=(");
            str.append(key.getElement());
            str.append(");");
        }

        if (m_locale != null) {
            str.append("locale=(");
            str.append(key.getLocale());
            str.append(");");
        }

        if (m_encoding != null) {
            str.append("encoding=(");
            str.append(key.getEncoding());
            str.append(");");
        }

        if (m_ip != null) {
            str.append("ip=(");
            str.append(key.getIp());
            str.append(");");
        }

        if (m_user != null) {
            str.append("user=(");
            str.append(key.getUser());
            str.append(");");
        }

        if (m_params != null) {
            str.append("params=(");
            Map keyParams = key.getParams();
            if (keyParams != null) {
                if (m_params.size() > 0) {
                    // match only params listed in cache directives
                    Iterator i = m_params.iterator();
                    while (i.hasNext()) {
                        Object o = i.next();
                        if (keyParams.containsKey(o)) {
                            str.append(o);
                            str.append("=");
                            // TODO: handle multiple occurances of the same parameter value
                            String[] values = (String[])keyParams.get(o);
                            str.append(values[0]);
                            if (i.hasNext()) {
                                str.append(",");
                            }
                        }
                    }
                } else {
                    // match all request params
                    Iterator i = keyParams.keySet().iterator();
                    while (i.hasNext()) {
                        Object o = i.next();
                        str.append(o);
                        str.append("=");
                        // TODO: handle multiple occurances of the same parameter value
                        String[] values = (String[])keyParams.get(o);
                        str.append(values[0]);
                        if (i.hasNext()) {
                            str.append(",");
                        }
                    }
                }
            }
            str.append(")");
        }

        if (m_session != null) {
            StringBuffer buf = new StringBuffer(32);
            boolean found = false;
            buf.append("session=(");
            HttpSession keySession = key.getSession();
            if (keySession != null) {
                // match only session attributes listed in cache directives
                Iterator i = m_session.iterator();
                while (i.hasNext()) {
                    String name = (String)i.next();
                    Object val = keySession.getAttribute(name);
                    if (val != null) {
                        found = true;
                        buf.append(name);
                        buf.append("=");
                        buf.append(val);
                        if (i.hasNext()) {
                            buf.append(",");
                        }
                    }
                }
            }
            if (found) {
                buf.append(")");
                str.append(buf);
            }
        }

        if (m_schemes != null) {
            String s = key.getScheme();
            if ((m_schemes.size() > 0) && (!m_schemes.contains(s))) {
                return null;
            }
            str.append("schemes=(");
            str.append(s);
            str.append(");");
        }

        if (m_ports != null) {

After Change


        }

        if (m_uri != null) {
            appendKeyValue(str, CACHE_02_URI, key.getUri());
        }

        if (m_site != null) {
            appendKeyValue(str, CACHE_17_SITE, key.getSite());
        }

        if (m_element != null) {
            appendKeyValue(str, CACHE_14_ELEMENT, key.getElement());
        }

        if (m_locale != null) {
            appendKeyValue(str, CACHE_15_LOCALE, key.getLocale());
        }

        if (m_encoding != null) {
            appendKeyValue(str, CACHE_16_ENCODING, key.getEncoding());
        }

        if (m_ip != null) {
            appendKeyValue(str, CACHE_13_IP, key.getIp());
        }

        if (m_user != null) {
            appendKeyValue(str, CACHE_03_USER, key.getUser());
        }

        if (m_params != null) {
            str.append(CACHE_04_PARAMS);
            str.append("=(");
            Map keyParams = key.getParams();
            if (keyParams != null) {
                if (m_params.size() > 0) {
                    // match only params listed in cache directives
                    Iterator i = m_params.iterator();
                    while (i.hasNext()) {
                        Object o = i.next();
                        if (keyParams.containsKey(o)) {
                            str.append(o);
                            str.append("=");
                            // TODO: handle multiple occurances of the same parameter value
                            String[] values = (String[])keyParams.get(o);
                            str.append(values[0]);
                            if (i.hasNext()) {
                                str.append(",");
                            }
                        }
                    }
                } else {
                    // match all request params
                    Iterator i = keyParams.keySet().iterator();
                    while (i.hasNext()) {
                        Object o = i.next();
                        str.append(o);
                        str.append("=");
                        // TODO: handle multiple occurances of the same parameter value
                        String[] values = (String[])keyParams.get(o);
                        str.append(values[0]);
                        if (i.hasNext()) {
                            str.append(",");
                        }
                    }
                }
            }
            str.append(");");
        }

        if (m_session != null) {
            StringBuffer buf = new StringBuffer(32);
            boolean found = false;
            buf.append(CACHE_07_SESSION);
            buf.append("=(");
            HttpSession keySession = key.getSession();
            if (keySession != null) {
                // match only session attributes listed in cache directives
                Iterator i = m_session.iterator();
                while (i.hasNext()) {
                    String name = (String)i.next();
                    Object val = keySession.getAttribute(name);
                    if (val != null) {
                        found = true;
                        buf.append(name);
                        buf.append("=");
                        buf.append(val);
                        if (i.hasNext()) {
                            buf.append(",");
                        }
                    }
                }
            }
            if (found) {
                buf.append(");");
                str.append(buf);
            }
        }

        if (m_schemes != null) {
            String s = key.getScheme();
            if ((m_schemes.size() > 0) && (!m_schemes.contains(s))) {
                return null;
            }
            appendKeyValue(str, CACHE_08_SCHEMES, s);
        }

        if (m_ports != null) {
            Integer i = key.getPort();
            if ((m_ports.size() > 0) && (!m_ports.contains(i))) {
                return null;
            }
            str.append(CACHE_09_PORTS);
            str.append("=(");
            str.append(i);
            str.append(");");
        }

        if (m_timeout > 0) {
            str.append(CACHE_06_TIMEOUT);
            str.append("=(");
            str.append(m_timeout);
            str.append(");");
        }